<?php 
//Bug in I.E 8 with multibyte characters, if not url encoded
$this->params['named']['category'] = urlencode($this->params['named']['category']);
$siteName = cr('cmsConfig.Backend.siteName');
	$CategoryModel = cri("ListCategory");
	$compareListing = false;
	if(cr('ListingConfig.enable_comparison') == true)
	{
		$compareListing = true;
	}
	$this->set("compareListing",$compareListing);
?>
<?php  if(!isset($this->params['isAjax']) || $this->params['isAjax'] != 1){?>
<!-- rss feed code starts here -->
<?php
if($hideRssFeed == false)
{?>
	<link rel="alternate" type="application/rss+xml" title="<?php echo sprintf(__("%s - %s Listings"),$siteName,$categoryData['ListCategory']['name'])?>" href="<?php echo $html->url('/listings/index/category/category:'.$categoryData['ListCategory']['slug'].'.'.'rss')?>">
<?php }?>
<!-- rss feed code ends here -->

<?php 
if(!empty($children))
{?>
	<div class="box_in sub_cat">
		<h5><?php echo __("Sub Categories")?></h5>
		<?php
    $children = Set::combine($children,'{n}.ListCategory.id','{n}');
    $childrenList = Set::combine($children,'{n}.ListCategory.id','{n}.ListCategory.name');
    asort($childrenList);
		foreach(array_keys($childrenList) as $childCategoryId)
		{
        $child = $children[$childCategoryId];
			?>
			<?php echo $appHtml->link($child['ListCategory']['name'],$child['ListCategory']['viewUrl']);?>
			<?php echo '('.$CategoryModel->getListingCount($child).')';?>
			<?php 
		}
		?>
	
	</div>	<br/>
<?php }?>
<div class="fl">
	<?php 
		if($session->read("Auth.User.id") && (cr('ListingConfig.listing_add_only_by_editor') != 1 || $session->read('Auth.User.is_editor') == 1))
		{
			echo $html->link('<span>'.__('New Listing').'</span>',array('controller'=>'listings','action'=>'add',$categoryData['ListCategory']['id'],'plugin'=>null), array('class' => 'button add','escape'=>false));
		}
	?>
</div>
<?php }?>
<?php 
	echo $this->render("index",false);
?>